package com.zhiyou.controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhiyou.model.AdminModel;
import com.zhiyou.service.Myservice;

@Controller
@RequestMapping("admin")
public class Mycontroller {
	@Autowired
	Myservice service;
@RequestMapping(value="index.do")
public String login(Model model) {
	List<AdminModel> list=service.SelectAllAdmin();
	model.addAttribute("list", list);
	
	System.out.println(11111);
	return "index";
}
@ResponseBody
@RequestMapping(value="selected.do",method=RequestMethod.POST)
public  HashMap saveSelected(Integer adminId,HttpServletRequest request) {
	System.out.println(adminId);
	HashMap map=new HashMap<>();
	map.put("message", request.getServletContext().getContextPath());
	
	return map;
}
@RequestMapping("reload.do")
public String reloadForm(Model model) {
	
	List<AdminModel> list=service.SelectAllAdmin();
	model.addAttribute("list", list);
	
	return "detail";
}
}
